package xyz.zhno.factory.simple.factory;

import xyz.zhno.factory.method.car.Car;
import xyz.zhno.factory.method.car.impl.Audi;
import xyz.zhno.factory.method.car.impl.Ford;
import xyz.zhno.factory.method.car.impl.Tesla;
import xyz.zhno.factory.simple.enums.CarTypeEnum;

/**
 * 汽车工厂
 * @author zh_o
 * @date 2020-11-11
 */
public class CarFactory {

    public static Car getCar(CarTypeEnum carType) {
        if (carType == null) {
            return null;
        }
        switch (carType) {
            case AUDI:
                return new Audi();
            case TESLA:
                return new Tesla();
            case FORD:
                return new Ford();
            default:
                return null;
        }
    }

}
